﻿using System;
using Netkk.Common.Models;

namespace Netkk.Models
{
    public class DownloadModel
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public string ContentType { get; set; }
        public int ContentSize { get; set; }
        public string FileName { get; set; }
        public string Description { get; set; }
        public bool ShowCreateDownload { get; set; }
        
        public static DownloadModel Create()
        {
            return new DownloadModel
            {
                Id = Guid.NewGuid(),
                Name = String.Empty,
                ContentSize = 0,
                ContentType = String.Empty,
                FileName = String.Empty,
                Description = String.Empty
            };
        }
        public static DownloadModel Create(Download download)
        {
            return new DownloadModel
                       {
                           Id = download.Id,
                           Name = download.Name,
                           ContentSize = download.ContentSize,
                           ContentType = download.ContentType,
                           FileName = download.FileName,
                           Description = download.Description
                       };
        }
        public static DownloadModel Create(Download download, bool allowEditOrAdd)
        {
            return new DownloadModel
            {
                Id = download.Id,
                Name = download.Name,
                ContentSize = download.ContentSize,
                ContentType = download.ContentType,
                FileName = download.FileName,
                Description = download.Description,
                ShowCreateDownload = allowEditOrAdd
            };
        }

        public Download MapToDownload()
        {
            return new Download
                       {
                           Id = Id,
                           Name=Name, 
                           ContentSize = ContentSize,
                           ContentType = ContentType,
                           FileName = FileName,
                           Description = Description
                       };
        }
    }
}
